let mongoose = require('./db')
let Schema = mongoose.Schema
let roleSchema = Schema({
    name: String
})
let userSchema = Schema({
    username: String,
    password: String,
    name: String,
    avatar: String,
    roles: {
        type: mongoose.Types.ObjectId,
        ref: 'role',
    },
})
let menuSchema = Schema({
    pid: {
        type: mongoose.Types.ObjectId,
        ref: 'menu',
    },
    name: String,  // 名称
    path: String,  // 文件地址
    redirect: String, // 重定向
    component: String,  // 组件
    icon: String,
    key: String,
    keepAlive: Boolean,
})

let roleModel = mongoose.model('role', roleSchema, 'role')
let userModel = mongoose.model('user', userSchema, 'user')
let menuModel = mongoose.model('menu', menuSchema, 'menu')

module.exports = {
    roleModel,
    userModel,
    menuModel
}
